﻿@model yq.IBase.Table.TableInfo
@{
    Layout = null;
}
using System;
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using yq.IBase; 
using yq.IBase.Basis;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc; 
using cn.Util; 

namespace yq.Model.Logic 
{ 
     ///<summary>
    /// @(Model.Name) - 对象继承类
    /// </summary>
[Table("@(Model.Code)")] [MetadataType(typeof(@(Model.ClassName)ValidaTion))] 
public class @Model.ClassName:ModelBase<@(Model.ClassName)> {
@{ bool iskey = true;}
@foreach (var info in Model.Columns)
{
 
    
    <text> 

         /// <summary>
        /// @info.Name
        /// </summary>
        private @(Tool.GetTypeName(info.DataType)) _@(info.Code) @Html.Raw(Tool.GetTypeValue(info.DataType,info.Stereotype));


        ///<summary>
        /// @info.Name
        ///</summary>
    @if (iskey)
    {
        @Html.Raw("       [FromDb(\"" + (info.Code) + "\",true)]");
    }
    else
    {
        @Html.Raw("       [FromDb(\"" + (info.Code) + "\")]");
    }
    @if (info.Stereotype.Length == 0 || (info.Stereotype.ToLower() != "bool" &&info.Stereotype.ToLower() != "enum"))
    {   
         <text> 
       public  @(Tool.GetTypeName(info.DataType, info.Stereotype, Model.ClassName, info.Code))  @(info.Code)
        { 
           get{ 
               return@(Tool.StringGet(info.Stereotype, Model.ClassName, info.Code))
           }
        
           set{
            @(Tool.StringSet(info.Stereotype, Model.ClassName, info.Code))
             } 
        } 
        </text>
    }
    else
    { 
    
     <text> 
         public @(Tool.GetTypeName(info.DataType,"", Model.ClassName, info.Code))  __@(info.Code)
         { 
           get
            { 
                return@(Tool.StringGet("", Model.ClassName,  info.Code))
            }
           set
            {
        @(Tool.StringSet("", Model.ClassName,  info.Code))
             } 
        } 
   
       public  @(Tool.GetTypeName(info.DataType, info.Stereotype, Model.ClassName, info.Code))  @(info.Code)
        { 
           get{ 
               return@(Tool.StringGet(info.Stereotype, Model.ClassName, info.Code))
           }
        
           set{
            @(Tool.StringSet(info.Stereotype, Model.ClassName, info.Code))
             } 
        } 
  </text>
    
        
        
        
    }
    


    </text>
    iskey = false;
}


        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
             @foreach (var info in Model.Columns)
            {
           @("           this.")@(info.Code)@("=")@("dy.")@(info.Code+";");
                         @("\r\n")                               
             }
        } 



  ///<summary>
 /// 辅助验证类
 /// </summary>
[Bind] 
public class @(Model.ClassName)ValidaTion {
@foreach (var info in Model.Columns)
{
    if (info.Code.Equals("Version"))
    {
        continue;
    }
    
    
    <text>
     /// <summary>
     /// @info.Name
     /// </summary>
    @Html.Raw(Tool.GetValidaTion(info.DataType, info.Stereotype, Model.ClassName, info.Code, info.Name, info.Mandatory, info.Length))
    public @(Tool.GetTypeName(info.DataType, info.Stereotype, Model.ClassName, info.Code)) @(info.Code)
    { get; set; }
    </text>
}
} } } 